<template>
  <el-dialog :title="dialogText[dialogStatusParkMag]" :visible.sync="dialogCreateVisibleDialog" center>
    <el-form ref="createFormParkMag" :rules="rulesParkMags" :inline="true" :model="tempParkMagDialog" :label-position="'left'"
             label-width="90px" style="text-align: center" >
      <el-form-item label="停车场编号" prop="park_no">
        <el-input clearable placeholder="请输入停车场编号" v-model="tempParkMagDialog.park_no"/>
      </el-form-item>
      <el-form-item label="停车场名称" prop="park_name" style="margin-left: 35px">
        <el-input v-model="tempParkMagDialog.park_name" clearable placeholder="请输入停车场名称"></el-input>
      </el-form-item>
      <el-form-item label="泊位数量" prop="park_placeno">
        <el-input clearable placeholder="请输入泊位数量" v-model="tempParkMagDialog.park_placeno"/>
      </el-form-item>
      <el-form-item label="泊位编号" prop="park_placeStart" style="margin-left: 35px">
        <el-input clearable placeholder="请输入泊位开始编号" v-model="tempParkMagDialog.park_placeStart"/>
      </el-form-item>
      <el-form-item label="所属单位" prop="park_ssdwname">
        <el-input v-model="tempParkMagDialog.park_ssdwname" clearable placeholder="请选择单位" readonly
                  @click.native="handleSelectDw"></el-input>
      </el-form-item>
      <el-form-item label="所在道路" prop="park_road" style="margin-left: 35px">
        <el-input v-model="tempParkMagDialog.park_road" clearable placeholder="请选择道路" readonly
                  @click.native="handleSelectRoad"></el-input>
      </el-form-item>
      <el-form-item label="收费标准" prop="park_sfbz">
        <el-select v-model="tempParkMagDialog.park_sfbz">
          <el-option v-for="item in sfbzs" :key="item.id" :label="item.value" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="park_status" style="margin-left: 35px">
        <el-select v-model="tempParkMagDialog.park_status">
          <el-option v-for="item in statuss" :key="item.id" :label="item.value" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="街道办事处" prop="park_jdbsc" >
        <el-input clearable placeholder="请输入街道办事处" v-model="tempParkMagDialog.park_jdbsc"/>
      </el-form-item>
      <el-form-item label="道路类型" prop="park_dllx" style="margin-left: 35px">
        <el-select v-model="tempParkMagDialog.park_dllx">
          <el-option v-for="item in dllxs" :key="item.id" :label="item.value" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="起始道路" prop="park_sroad" >
        <el-input clearable placeholder="请输入起始道路" v-model="tempParkMagDialog.park_sroad"/>
      </el-form-item>
      <el-form-item label="终止道路" prop="park_eroad" style="margin-left: 35px">
        <el-input clearable placeholder="请输入终止道路" v-model="tempParkMagDialog.park_eroad"/>
      </el-form-item>
      <el-form-item label="道路哪侧" prop="park_dlnc" >
        <el-select v-model="tempParkMagDialog.park_dlnc">
          <el-option v-for="item in dlncs" :key="item.id" :label="item.value" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="收费方式" prop="park_sffs" style="margin-left: 35px">
        <el-select v-model="tempParkMagDialog.park_sffs">
          <el-option v-for="item in sffss" :key="item.id" :label="item.value" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="经度" prop="park_long" >
        <el-input clearable placeholder="请输入经度" v-model="tempParkMagDialog.park_long"/>
      </el-form-item>
      <el-form-item label="纬度" prop="park_lati" style="margin-left: 35px">
        <el-input clearable placeholder="请输入纬度" v-model="tempParkMagDialog.park_lati"/>
      </el-form-item>
      <el-form-item label="营运起始时间" prop="park_sdate">
        <el-date-picker
          v-model="tempParkMagDialog.park_sdate"
          type="date" value-format="yyyy-MM-dd" placeholder="选择日期"></el-date-picker>
      </el-form-item>
      <el-form-item label="营运终止时间" prop="park_edate">
        <el-date-picker
          v-model="tempParkMagDialog.park_edate"
          type="date" value-format="yyyy-MM-dd" placeholder="选择日期"></el-date-picker>
      </el-form-item>
      <el-form-item label="检测方式" prop="park_jcfs" >
      <el-select v-model="tempParkMagDialog.park_jcfs">
        <el-option v-for="item in jcfss" :key="item.id" :label="item.value" :value="item.id"></el-option>
      </el-select>
      </el-form-item>
      <el-form-item label="备注" prop="park_remark" style="margin-left: 35px">
        <el-input clearable placeholder="请输入备注" v-model="tempParkMagDialog.park_remark"/>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogCreateVisibleDialog = false" class="btn-search">取消</el-button>
      <el-button v-if="dialogStatusParkMag=='create'" type="primary" class="btn-search" @click="createDataParkMag">确定</el-button>
      <el-button v-else type="primary" @click="updateDataParkMag" class="btn-search">确定</el-button>
    </div>
    <person-child-dialog-road :dialogRoadVisible.sync="dialogRoadVisiblParkMag"
                              @roadName="selectRoadNameParkMag"></person-child-dialog-road>
    <person-child-dialog-dw :dialogDwVisible.sync="dialogDwVisibleParkMg"  @dwName="selectDwnameParkMag" :dwType="dwTypeParkMag" ></person-child-dialog-dw>
  </el-dialog>
</template>

<script>
  /* eslint-disable */
  import PersonChildDialogDw from "../../organizationManagement/personChild/personChildDialogDw";
  import PersonChildDialogRoad from "../../organizationManagement/personChild/personChildDialogRoad";
  import {selDictonary} from "../../../api/dictionary";
  import {getChargeStandard} from "../../../api/parkingResource/parkingMag";

  export default {
    created(){
      this.initData()
    },
    components: {
      PersonChildDialogRoad,
      PersonChildDialogDw},
    name: "creat-parking-mag-dialog",
    props: ['dialogStatusParkMag', 'dialogVisible','tempParkMag'],
    watch: {
      dialogCreateVisibleDialog() {
        this.$emit('update:dialogVisible', this.dialogCreateVisibleDialog)
      },
      dialogVisible(val){
        this.dialogCreateVisibleDialog=val
      },
      tempParkMag(val){
        this.tempParkMagDialog=val
      }
    },

    data() {
      return {
        dialogText: {create: '新增', update: '编辑'},
        dialogCreateVisibleDialog: false,
        dialogDwVisibleParkMg: false,
        dialogRoadVisiblParkMag: false,
        tempParkMagDialog:{
          park_no: '',
          park_name: '',
          park_placeno: '',
          park_placeStart:'001',
          park_ssdw:'',
          park_ssdwname: '',park_sfbzname:'',
          park_sfbz: '', park_roadno: '', park_road: '', park_dllx: '',
          park_jdbsc: '', park_sroad: '', park_eroad: '', park_dlnc: '',
          park_sffs: '', park_jcfs: '', park_long: '', park_lati: '',
          park_sdate: '', park_edate: '', park_status: '1', park_remark: ''
        },
        sfbzs:[],
        statuss:[],
        dllxs:[],
        dlncs:[],
        sffss:[],
        jcfss:[],
        dwTypeParkMag:0,
        rulesParkMags: {
          park_no:[{required :true, message : '请输入停车场编号',trigger: 'blur' }],
          park_name:[{required :true, message : '请输入停车场名称',trigger: 'blur' }],
          park_placeno:[{required :true, message : '请输入泊位数',trigger: 'blur' }],
          park_ssdwname:[{required :true, message : '请选择单位编号',trigger: 'change' }],
          park_road:[{required :true, message : '请选择所在道路',trigger: 'change' }]
        }
      }
    },
    methods: {
      createDataParkMag() {
        this.$refs['createFormParkMag'].validate((valid) => {
          if (valid) {
          this.$emit('createDataParkMag',this.tempParkMagDialog)
          }
        })
      },
      updateDataParkMag() {
        this.$refs['createFormParkMag'].validate((valid) => {
          if (valid) {
            this.$emit('updateDataParkMag',this.tempParkMagDialog)
          }
        })
      },
      handleSelectDw(){
      this.dialogDwVisibleParkMg=true
      },
      selectDwnameParkMag(val){
        this.tempParkMagDialog.park_ssdwname=val.orgname
        this.tempParkMagDialog.park_ssdw=val.orgno
        this.dialogDwVisibleParkMg=false
      },
      handleSelectRoad(){
      this.dialogRoadVisiblParkMag=true
      },
      selectRoadNameParkMag(val){
        this.tempParkMagDialog.park_road=val.unitname
        this.tempParkMagDialog.park_roadno=val.unitno
        this.dialogRoadVisiblParkMag=false
      },
      initData(){
        selDictonary().then(res => {
          for (var item in res) {
            if (res[item].id == "ori") {//
              this.dlncs = res[item].comboboxDetailList
            } else if (res[item].id == "enableflag") {
              this.statuss = res[item].comboboxDetailList
            }else if (res[item].id == "roadtype"){
              this.dllxs=  res[item].comboboxDetailList
            }else if (res[item].id == "sffs"){
              this.sffss=  res[item].comboboxDetailList
            }else if (res[item].id == "jcfs"){
              this.jcfss=  res[item].comboboxDetailList
            }
          }
        })
        getChargeStandard().then(res => {
          this.sfbzs = res
        })
      }
    }
  }
</script>

<style scoped>

</style>
